#include "whalefollowerentry.h"

#include <QHBoxLayout>
#include <QLabel>
#include <QTextBrowser>
#include <QVariant>
#include <QVBoxLayout>

WhaleFollowerEntry::WhaleFollowerEntry( QVariantMap user, QWidget * parent )
    : WhaleAbstractEntry( user, parent ) {

    this->mName = user[ "screen_name" ].toString();
    this->mAvatarUrl = user[ "profile_image_url" ].toString();
    QString userId = user[ "id" ].toString();
    QString description = user[ "description" ].toString();
    bool hisFriend = user[ "friend" ].toBool();

    QHBoxLayout * layout = new QHBoxLayout();
    layout->setMargin( 0 );
    layout->setSpacing( 0 );

    this->mAvatarLabel = new WhaleAvatar( this->mAvatarUrl, userId );

    /*
    QTextBrowser * browser = new QTextBrowser();
    browser->setOpenLinks( false );
    browser->setOpenExternalLinks( true );
    browser->setText( "<b>" + this->mName + "</b>: " + description );
    browser->setHorizontalScrollBarPolicy( Qt::ScrollBarAlwaysOff );
    browser->setFixedHeight( 80 );
    */
    QLabel * userLabel = new QLabel( "<b>" + this->mName + "</b>: " + description );
    userLabel->setWordWrap( true );
    userLabel->setFixedWidth( 360 );

    QVBoxLayout * rightlayout = new QVBoxLayout();
    rightlayout->addWidget( userLabel );
    // rightlayout->addWidget( browser );

    /*
    if ( hisFriend ) {
        rightlayout->addWidget( new QLabel( this->mName + " is following you" ) );
    }
    else {
        rightlayout->addWidget( new QLabel( this->mName + " is not following you" ) );
    }
    */

    layout->addWidget( this->mAvatarLabel );
    layout->addWidget( userLabel );
    // layout->addLayout( rightlayout );
    this->setLayout( layout );

    // this->setSizePolicy( QSizePolicy( QSizePolicy::Ignored, QSizePolicy::Fixed ) );
}
